package com.study.spmongodb.book.wwj.char09;

/**
 * @author MI
 * @version 1.0
 * @date 2020/11/26 10:22
 */
public class Singleton {
    //位置2 移动到 位置1 前面结果会不同
    //位置1
    private static int x = 0;

    private static int y;

    //位置2
    private static Singleton instance = new Singleton();

    private Singleton() {
        x++;
        y++;
    }

    private static Singleton getInstance() {
        return instance;
    }

    public static void main(String[] args) {
        final Singleton instance = Singleton.getInstance();
        System.out.println(instance.x);
        System.out.println(instance.y);
    }
}
